﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using WpfColor = System.Windows.Media.Color;
using GdiColor = System.Drawing.Color;

using StandardColorPair = HFUTCourseSimulation.Util.ColorPair;
using StorageColorPair = HFUTCourseSimulation.Kernel.Data.Storage.ColorPair;

namespace HFUTCourseSimulation.Util {

    public static class ColorTrans {

        #region Color Transform

        public static GdiColor ToGdiColor(int argb) {
            return GdiColor.FromArgb(argb);
        }

        public static GdiColor ToGdiColor(WpfColor c) {
            return GdiColor.FromArgb(c.A, c.R, c.G, c.B);
        }

        public static WpfColor ToWpfColor(int _argb) {
            var argb = (uint)_argb;
            var a = (argb & 0xff000000) >> 24;
            var r = (argb & 0x00ff0000) >> 16;
            var g = (argb & 0x0000ff00) >> 8;
            var b = (argb & 0x000000ff);
            return WpfColor.FromArgb((byte)a, (byte)r, (byte)g, (byte)b);
        }

        public static WpfColor ToWpfColor(GdiColor c) {
            return WpfColor.FromArgb(c.A, c.R, c.G, c.B);
        }

        public static int ToInt(GdiColor c) {
            return c.ToArgb();
        }

        public static int ToInt(WpfColor c) {
            uint argb = 0;
            argb |= c.A; argb <<= 8;
            argb |= c.R; argb <<= 8;
            argb |= c.G; argb <<= 8;
            argb |= c.B;
            return (int)argb;
        }

        #endregion

        #region Color Pair

        public static StandardColorPair ToStandardColorPair(StorageColorPair cp) {
            return new StandardColorPair() {
                Background = cp.Background,
                Foreground = cp.Foreground
            };
        }

        public static StorageColorPair ToStorageColorPair(StandardColorPair cp) {
            return new StorageColorPair() {
                Background = cp.Background,
                Foreground = cp.Foreground
            };
        }

        #endregion

    }
}
